//------------------------------------------------------------------------------//
//
// MODULE	: ltservershell.h
//
// PURPOSE	: CLTServerShell - Definition
//
// CREATED	: 02/03/2002
//
// (c) 2002 LithTech, Inc.	All Rights Reserved
//
//------------------------------------------------------------------------------//

#ifndef __LT_SERVER_SHELL_H__
#define __LT_SERVER_SHELL_H__

// Definitions of members classes


// Base class for server shell
//#include <iservershell.h>
#include "Avatar.h"
#include <set>
#include <boost/shared_ptr.hpp>
#include <boost/scoped_ptr.hpp>
#include "message_manager.h"

class world_properties ;

class car_road_info_manager ;
class game_logic_shell ;
class light_system ;

namespace Utility {
    
    class node_record_manager ;
}

namespace GameLogic {
    class car ;
}




//-----------------------------------------------------------------------------
class CLTServerShell : public IServerShellStub
{

public:
    CLTServerShell();
    ~CLTServerShell() ;

    declare_interface(CLTServerShell);

    // Overridden functions, to receive callbacks from the engine
    //	These are all overridden here to make modification easier.
    //	Documentation exists in engine/sdk/inc/iservershell.h in the
    //	 IServerShell class
    LTRESULT	OnServerInitialized();
    void		OnServerTerm();
    void		SRand(unsigned int uiRand);
    void		PreStartWorld(bool bSwitchingWorlds);
    void		PostStartWorld();
    void		OnAddClient(HCLIENT hClient);
    void		OnRemoveClient(HCLIENT hClient);
    LPBASECLASS OnClientEnterWorld(HCLIENT hClient);
    void		OnClientExitWorld(HCLIENT hClient);
    void		Update(LTFLOAT timeElapsed);
    void		OnMessage(HCLIENT hSender,
                      ILTMessage_Read *pMessage);
    void		OnObjectMessage(LPBASECLASS pSender,
                            uint32 messageID,
                            ILTMessage_Read* pMessage);
    void		OnPlaybackFinish();
    void		CacheFiles();
    LTRESULT	FileLoadNotify(const char *pFilename, LTRESULT status);
    LTRESULT	ServerAppMessageFn(const char *pMsg);
    LTRESULT	ProcessPacket(ILTMessage_Read *pMsg, uint8 senderAddr[4],
                            uint16 senderPort);
    void register_object(world_properties* pWorldProps) ;
    void unregister_object(world_properties* pWorldProps) ;
    static HOBJECT handle_object_of_client(HCLIENT client) ;
private:
    
    world_properties *m_pWorldProperties;
private:
    
    boost::scoped_ptr<game_logic_shell> m_game_logic ;
public:
    game_logic_shell* game_logic_shell() {return m_game_logic.get() ;}
    boost::shared_ptr<light_system> m_lights ;
    
};

extern CLTServerShell *g_pSShell ;


#endif //__LT_SERVER_SHELL_H__
